//---------------------------------------------------------------------
//  This file is part of the Background Motion solution.
// 
//  Copyright (C) Mindscape (TM).  All rights reserved.
//  http://www.mindscape.co.nz
// 
//  THIS CODE AND INFORMATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY
//  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
//  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//  PARTICULAR PURPOSE.
//---------------------------------------------------------------------

using System;

namespace Mindscape.BackgroundMotion.Core.Model
{
  /// <summary>
  /// Contract which describes a unit of work which can be completed by a Repository
  /// </summary>
  public interface IUnitOfWork : IDisposable
  {
    /// <summary>
    /// Fires when the unit of work is being disposed
    /// </summary>
    event EventHandler Disposed;

    /// <summary>
    /// Signals that the unit of work has completed successfully
    /// </summary>
    void Complete();

    /// <summary>
    /// Returns the instance of the repository associated with the generic type which is being used by this unit of work
    /// </summary>
    /// <typeparam name="T">The generic type of the entity being persisted</typeparam>
    /// <returns>The instance of the repository handling the request</returns>
    IRepository<T> GetRepository<T>() where T : class, IIdentifiable;
  }
}